package com.scott.ch300.lambda.ch01;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author 黄后林   Add unambiguous imports on the fly
 * @version 1.0
 * @note
 * @date 2022-06-26 13:12:42
 */
public class LambdaTest {


    List<Student> studentList = Arrays.asList(
            new Student("张无忌",18,180,35000),
            new Student("周芷若",30,182,45000),
            new Student("赵敏",26,185,55000),
            new Student("小昭",24,177,36000),
            new Student("灭绝师太",32,171,13000)
    );


    @Test
    public void salary(){
        System.out.println(findSalary(studentList));
    }

    @Test
    public void height(){
        System.out.println(findHeight(studentList));
    }

    private List<Student> findSalary(List<Student> list){

        List<Student> rs = new ArrayList<>();
        for(Student student :list){

            // 工资大于25000
            if(student.getSalary() > 25000){
                rs.add(student);
            }
        }
        return rs;
    }

    private List<Student> findHeight(List<Student> list){

        List<Student> rs = new ArrayList<>();
        for(Student student :list){

            // 身高大于180
            if(student.getHeight()>180){
                rs.add(student);
            }
        }
        return rs;
    }
}
